package com.glory.brepda.adapter;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.activity.check.CheckInspectionActivity;
import com.glory.brepda.activity.check.NewCheckTableActivity;
import com.glory.brepda.base.BaseActivity;
import com.glory.brepda.entity.SheetInfoEntity;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ToastUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_Utils;

import java.util.List;

/**
 * FileName: CheckQueryListAdapter
 * Author: XJH
 * Date: 2020/9/2 16:22
 * Description:
 * History:
 */
public class CheckQueryListAdapter extends BaseQuickAdapter<SheetInfoEntity, BaseViewHolder> {

    private OnClickListener mListener;

    public CheckQueryListAdapter(@Nullable List<SheetInfoEntity> data) {
        super(R.layout.adapter_check_query, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SheetInfoEntity item) {
        helper.setText(R.id.tvCheckID,item.getOBJECTRRN());
        helper.setText(R.id.tvClazz,item.getGROUP2() + "/" + item.getGROUP1());
        helper.setText(R.id.tvEqp,item.getEQUIPMENTID());
        helper.setText(R.id.tvLocation,item.getRESERVED1() + "/" + item.getEQUIPMENTTYPE());
        helper.setText(R.id.tvCheckTime,item.getCREATED().split(" ")[0]);
        helper.setText(R.id.tvCheckMan,item.getUPDATEDBY());
        helper.setText(R.id.tvCheckStatus,item.getRESERVED3());

        helper.getView(R.id.tvCheckStatus).setOnClickListener(view -> {
            if (mListener != null){
                mListener.onCheckListener(item);
            }
        });
    }

    public interface OnClickListener{
        void onCheckListener(SheetInfoEntity item);
    }

    public void setOnCheckListener(OnClickListener listener){
        this.mListener = listener;
    }
}
